package cn.getech.data.development.mapper.dataMap;

import cn.getech.data.development.entity.TableInfo;
import cn.getech.data.development.entity.dataMap.SearchHistory;
import cn.getech.data.development.entity.dataMap.TableInfoSearch;
import cn.getech.data.development.entity.dataMap.TargetSearch;
import cn.getech.data.development.entity.flink.BdpRealTableInfo;
import cn.getech.data.development.model.req.search.DataSearchReq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
public interface SearchHistoryMapper extends BaseMapper<SearchHistory> {

    List<TableInfoSearch> searchTablePage(@Param("params") DataSearchReq params);
    IPage<TableInfoSearch> searchTablePage(IPage<TableInfoSearch> dataPage, @Param("params") DataSearchReq params);

    List<Map<String, Object>> selectSubjectList(@Param("ids") Set<Integer> subject);
    List<Map<String, Object>> selectProcListList(@Param("ids") Set<Integer> project);

    List<TableInfoSearch> searchFieldPage(@Param("params") DataSearchReq params);
    IPage<TableInfoSearch> searchFieldPage(IPage<TableInfoSearch> dataPage, @Param("params") DataSearchReq params);

    List<TargetSearch> searchTargetPage(@Param("params") DataSearchReq params);
    IPage<TargetSearch> searchTargetPage(IPage<TargetSearch> dataPage, @Param("params")  DataSearchReq params);

    TableInfo getTableById(@Param("id") Integer id);

    int addViewNum(@Param("id") Integer id, @Param("type") Integer type, @Param("num") Integer num);

    String getTargetName(@Param("id") Integer id);

    String getDataSource(@Param("id") Integer id);

    String getDataService(@Param("id") Integer id);

    String getCollectTask(@Param("id") Integer id);

    Map <String, Object> getBusinessById(@Param("id") Integer id);

    BdpRealTableInfo getRealTableById(@Param("id") Integer id);

    String getSubjectArea(@Param("tableType") Integer tableType, @Param("id") Integer id);

    @Select("SELECT data_service_group.service_group_name AS NAME FROM data_service_group WHERE data_service_group.id = #{groupId}")
    String queryNameById(@Param("groupId")Integer groupId);
}